]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
WorkspaceBackground: Fully take care of workarea geometry on allocation
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Fri, 18 Jun 2021 17:11:34 +0000 (19:11 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Fri, 16 Jul 2021 22:25:50 +0000 (00:25 +0200)
The background group is currently allocated taking care of the workarea
x, y offset but not of its width/height and this may lead to building a
wrongly sized workspace view when the workarea size is not matching the
monitor size (like when there are struts set).

So, take care of the difference between the workarea and monitor
absolute end coordinates to allocate the background scaled content box.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1892>

js/ui/workspace.js

index 75efe4d992e41859d86fd6b35a26e7b7afc1ee4c..fafa368ce75c4313cf021c56b541ec905efbe9b3 100644 (file)
@@ -1012,13 +1012,21 @@ class WorkspaceBackground extends St.Widget {
 
         const [contentWidth, contentHeight] = contentBox.get_size();
         const monitor = Main.layoutManager.monitors[this._monitorIndex];
-        const xOff = (contentWidth / this._workarea.width) *
-            (this._workarea.x - monitor.x);
-        const yOff = (contentHeight / this._workarea.height) *
-            (this._workarea.y - monitor.y);
-
-        contentBox.set_origin(-xOff, -yOff);
-        contentBox.set_size(xOff + contentWidth, yOff + contentHeight);
+        const [mX1, mX2] = [monitor.x, monitor.x + monitor.width];
+        const [mY1, mY2] = [monitor.y, monitor.y + monitor.height];
+        const [wX1, wX2] = [this._workarea.x, this._workarea.x + this._workarea.width];
+        const [wY1, wY2] = [this._workarea.y, this._workarea.y + this._workarea.height];
+        const xScale = contentWidth / this._workarea.width;
+        const yScale = contentHeight / this._workarea.height;
+        const leftOffset = wX1 - mX1;
+        const topOffset = wY1 - mY1;
+        const rightOffset = mX2 - wX2;
+        const bottomOffset = mY2 - wY2;
+
+        contentBox.set_origin(-leftOffset * xScale, -topOffset * yScale);
+        contentBox.set_size(
+            contentWidth + (leftOffset + rightOffset) * xScale,
+            contentHeight + (topOffset + bottomOffset) * yScale);
         this._backgroundGroup.allocate(contentBox);
     }